package designMode.iteratorPattern;

import java.util.ArrayList;
import java.util.List;

/**
 * @author LIBOFEI
 * @ClassName PancakeHouseMenu
 * @description  一个菜单的实现，使用ArrayList实现数据存储
 * @date 2020/6/26 16:03
 * @Version 1.0
 **/
public class PancakeHouseMenu implements MenuIterator{

    private static final int MAX_SIZE = 5;

    private ArrayList<MenuItem> menuItems;

    public PancakeHouseMenu(){
        menuItems = new ArrayList();
        for(int i = 0; i < MAX_SIZE ; i++){
            addItem("pancakeName" + i, "pancakeContent" + i, true,i);
        }
    }

    public void addItem(String name,String description,boolean vegetarian,double price){
        MenuItem menuItem = new MenuItem(name,description,vegetarian,price);
        menuItems.add(menuItem);
    }

    public ArrayList<MenuItem> getMenuItems() {
        return menuItems;
    }

    /** *
     * 迭代器模式，创建迭代器，返回
     * @author LIBOFEI
     * @date 16:35 2020/6/26
     * @return designMode.iteratorPattern.Iterator
     * @Version  1.0
     **/
//    public Iterator createIterator(){
//        return new PancakerHouseMenuIterator(menuItems);
//    }
    @Override
    public java.util.Iterator createIterator(){
        return menuItems.iterator();
    }


    @Override
    public String toString() {
        return "PancakeHouseMenu{" +
                "menuItems=" + menuItems +
                '}';
    }
}
